@ninjainfosys/site-kit 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/package.json +1 -1
- package/src/integration.mjs +13 -4
- package/src/lib/rehype-posts.mjs +66 -4
- package/src/pages/blog/[slug].astro +39 -38
- package/src/pages/glossary/[slug].astro +2 -2
- package/src/pages/glossary/index.astro +1 -1
- package/src/scripts/check-site.mjs +12 -4
- package/src/styles/article.css +95 -0
- package/src/styles/blog-serif.css +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ The package ships `.astro` and `.ts` source. The integration tells Vite to compi
|
|
|
37
37
|
|
|
38
38
|
| Page | Routes | Turn off with |
|
|
39
39
|
| --- | --- | --- |
|
|
40
|
-
| `blog` | `/blog`, `/blog/[slug]`, `/blog/page/[page]`, `/blog/tag/[tag]` | `pages: { blog: false }` (a site
|
|
40
|
+
| `blog` | `/blog`, `/blog/[slug]`, `/blog/page/[page]`, `/blog/tag/[tag]` | `pages: { blog: false }` (a site that needs a different blog supplies its own pages) |
|
|
41
41
|
| `glossary` | `/glossary`, `/glossary/[slug]` | `pages: { glossary: false }` |
|
|
42
42
|
| `og` | `/og/[...slug].png` | `pages: { og: false }` |
|
|
43
43
|
| `rss` | `/rss.xml` | `pages: { rss: false }` |
|
|
@@ -72,9 +72,24 @@ A post whose `date` is after the build day (YYYY-MM-DD) is left out of every pro
|
|
|
72
72
|
|
|
73
73
|
## Post bodies
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
What authors can write in a post's Markdown, and what the kit does with it:
|
|
76
|
+
|
|
77
|
+
| Write | You get |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `> [!NOTE]` then the text | A panel with an info icon and the label "Note". |
|
|
80
|
+
| `> [!TIP]` | The same panel with a bulb and "Tip". |
|
|
81
|
+
| `> [!WARNING]` | A warm tinted panel with an alert icon and "Watch out". |
|
|
82
|
+
| `> [!STAT]`, then the number on the first line, then a caption | A large number (2rem, 600) with the caption under it. |
|
|
83
|
+
| `> text` | A quote: larger text with a quote mark, no stripe. |
|
|
84
|
+
| `1. 2. 3.` | Steps with the number in a 28px circle. |
|
|
85
|
+
| `- item` | Bullets in the accent colour. |
|
|
86
|
+
| A Markdown table | A bordered box that scrolls sideways. The header and first column stay in view, rows are striped, and columns of numbers and prices are right-aligned. |
|
|
87
|
+
| `` alone in a paragraph | A figure with a visible caption. On wide screens it reaches into the contents rail's space. |
|
|
88
|
+
| `[text](/blog/other-post)` | A link, unless that post is a draft or scheduled for later. Then plain text. The same goes for `/glossary/<term>` links to terms not released yet. |
|
|
89
|
+
|
|
90
|
+
On every post page the kit also adds: a "#" link on hover or focus beside each H2, a "Copy link" button by the date line, a thin reading-progress bar (hidden under reduced motion) and the "Questions people ask" accordion with the first answer open. "Updated" shows only when `updated` is a later day than `date`. Callouts, tables and the unlinking apply only to files in `src/content/blog`.
|
|
91
|
+
|
|
92
|
+
The article styles use only the site's tokens: `--canvas --surface --subtle --line --ink --ink-muted --link --mark --warn-bg --warn-ink --font-sans --font-display --font-mono --font-serif --radius-panel --radius-control`. `--mark` is the accent for bullets and the progress bar. `--warn-bg` and `--warn-ink` are the warning panel (keep the text at AA contrast). A site that is strictly black and white points them at its greys.
|
|
78
93
|
|
|
79
94
|
## Commands
|
|
80
95
|
|
package/package.json
CHANGED
package/src/integration.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { rehypeFigures } from './lib/rehype-figures.mjs';
|
|
7
|
-
import { rehypeTables, rehypeUnlinkHidden } from './lib/rehype-posts.mjs';
|
|
7
|
+
import { rehypeCallouts, rehypeTables, rehypeUnlinkHidden } from './lib/rehype-posts.mjs';
|
|
8
8
|
|
|
9
9
|
const PACKAGE = '@ninjainfosys/site-kit';
|
|
10
10
|
const BLOG_IMAGES = 'virtual:site-kit/blog-images';
|
|
@@ -27,7 +27,16 @@ function postStatus(root, dev) {
|
|
|
27
27
|
const showScheduled = process.env.SHOW_SCHEDULED === '1';
|
|
28
28
|
const shipping = [];
|
|
29
29
|
const hidden = [];
|
|
30
|
-
|
|
30
|
+
const hiddenTerms = [];
|
|
31
|
+
const terms = join(root, 'src/data/glossary/terms');
|
|
32
|
+
if (!dev && existsSync(terms)) {
|
|
33
|
+
for (const f of readdirSync(terms).filter((x) => x.endsWith('.ts'))) {
|
|
34
|
+
const src = readFileSync(join(terms, f), 'utf8');
|
|
35
|
+
const published = src.match(/\bpublished:\s*['"](\d{4}-\d{2}-\d{2})['"]/)?.[1];
|
|
36
|
+
if (published && published > today && !showScheduled) hiddenTerms.push(src.match(/\bslug:\s*['"]([^'"]+)['"]/)?.[1] ?? f.replace(/\.ts$/, ''));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!existsSync(dir)) return { shipping, hidden, hiddenTerms };
|
|
31
40
|
for (const f of readdirSync(dir).filter((x) => x.endsWith('.md'))) {
|
|
32
41
|
const fm = readFileSync(join(dir, f), 'utf8').match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? '';
|
|
33
42
|
const date = fm.match(/^date:\s*["']?(\d{4}-\d{2}-\d{2})/m)?.[1];
|
|
@@ -35,7 +44,7 @@ function postStatus(root, dev) {
|
|
|
35
44
|
const scheduled = !showScheduled && !!date && date > today;
|
|
36
45
|
(!dev && (draft || scheduled) ? hidden : shipping).push(f.replace(/\.md$/, ''));
|
|
37
46
|
}
|
|
38
|
-
return { shipping, hidden };
|
|
47
|
+
return { shipping, hidden, hiddenTerms };
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
function blogImages(root, dev) {
|
|
@@ -87,7 +96,7 @@ export default function siteKit(options = {}) {
|
|
|
87
96
|
const root = fileURLToPath(config.root);
|
|
88
97
|
const status = postStatus(root, command === 'dev');
|
|
89
98
|
updateConfig({
|
|
90
|
-
markdown: { rehypePlugins: [rehypeFigures, rehypeTables, [rehypeUnlinkHidden, { hidden: status.hidden }]] },
|
|
99
|
+
markdown: { rehypePlugins: [rehypeFigures, rehypeCallouts, rehypeTables, [rehypeUnlinkHidden, { hidden: status.hidden, hiddenTerms: status.hiddenTerms }]] },
|
|
91
100
|
vite: {
|
|
92
101
|
plugins: [
|
|
93
102
|
{
|
package/src/lib/rehype-posts.mjs
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
//
|
|
7
7
|
// rehypeUnlinkHidden turns a link to /blog/<slug> into plain text when that
|
|
8
8
|
// post is a draft or scheduled for later, so a shipping page never links to a
|
|
9
|
-
// page that is not built.
|
|
9
|
+
// page that is not built. The same goes for a link to a glossary term that is
|
|
10
|
+
// not released yet. Links to pages that do not exist are left alone.
|
|
10
11
|
|
|
11
12
|
const NUM = /^[~≈<>+]?\s*(?:Rs\.?|NPR|US\$|\$)?\s*\d[\d,.]*\s*(?:%|[kKmM]\b|MB|GB|TB|Mbps|MP|days?|hrs?|months?|years?)?(?:\s*(?:–|-|to)\s*(?:Rs\.?|NPR|\$)?\s*\d[\d,.]*\s*(?:%|[kKmM]\b|MB|GB|TB|MP|days?)?)?(?:\s*\/\s*\w+)?$/i;
|
|
12
13
|
|
|
@@ -54,10 +55,10 @@ export function rehypeTables() {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export function rehypeUnlinkHidden(options = {}) {
|
|
57
|
-
const hidden = new Set(options.hidden ?? []);
|
|
58
|
+
const hidden = new Set([...(options.hidden ?? []).map((s) => `blog/${s}`), ...(options.hiddenTerms ?? []).map((s) => `glossary/${s}`)]);
|
|
58
59
|
const slugOf = (href) => {
|
|
59
|
-
const m = String(href ?? '').match(/^(?:https?:\/\/[^/]+)?\/blog\/([^/?#]+)\/?(?:[?#].*)?$/);
|
|
60
|
-
return m ? m[1] : null;
|
|
60
|
+
const m = String(href ?? '').match(/^(?:https?:\/\/[^/]+)?\/(blog|glossary)\/([^/?#]+)\/?(?:[?#].*)?$/);
|
|
61
|
+
return m ? `${m[1]}/${m[2]}` : null;
|
|
61
62
|
};
|
|
62
63
|
const walk = (node) => {
|
|
63
64
|
if (!node.children) return;
|
|
@@ -69,3 +70,64 @@ export function rehypeUnlinkHidden(options = {}) {
|
|
|
69
70
|
};
|
|
70
71
|
return (tree) => walk(tree);
|
|
71
72
|
}
|
|
73
|
+
|
|
74
|
+
// Callouts from Markdown, in GitHub's alert syntax:
|
|
75
|
+
//
|
|
76
|
+
// > [!NOTE] > [!TIP] > [!WARNING] > [!STAT]
|
|
77
|
+
// > text
|
|
78
|
+
//
|
|
79
|
+
// A blockquote that starts with one of these markers becomes
|
|
80
|
+
// <aside class="callout callout-note">. STAT shows its first line as a large
|
|
81
|
+
// number and the rest as a caption.
|
|
82
|
+
const ICONS = {
|
|
83
|
+
note: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',
|
|
84
|
+
tip: '<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/>',
|
|
85
|
+
warning: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
|
|
86
|
+
};
|
|
87
|
+
const LABELS = { note: 'Note', tip: 'Tip', warning: 'Watch out' };
|
|
88
|
+
const el = (tagName, properties = {}, children = []) => ({ type: 'element', tagName, properties, children });
|
|
89
|
+
const camel = (k) => k.replace(/-(\w)/g, (_, c) => c.toUpperCase());
|
|
90
|
+
// The icon strings above as hast nodes (no raw HTML, so any Markdown pipeline accepts them).
|
|
91
|
+
const icon = (kind) => el('svg', { viewBox: '0 0 24 24', width: 18, height: 18, fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round', ariaHidden: 'true' },
|
|
92
|
+
[...ICONS[kind].matchAll(/<(\w+)([^>]*)\/>/g)].map((m) => el(m[1], Object.fromEntries([...m[2].matchAll(/([\w-]+)="([^"]*)"/g)].map((a) => [camel(a[1]), a[2]])))));
|
|
93
|
+
|
|
94
|
+
export function rehypeCallouts() {
|
|
95
|
+
const walk = (node) => {
|
|
96
|
+
if (!node.children) return;
|
|
97
|
+
node.children = node.children.map((child) => {
|
|
98
|
+
if (isEl(child, 'blockquote')) {
|
|
99
|
+
const made = callout(child);
|
|
100
|
+
if (made) return made;
|
|
101
|
+
}
|
|
102
|
+
walk(child);
|
|
103
|
+
return child;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
function callout(bq) {
|
|
107
|
+
const kids = bq.children.filter((k) => !(k.type === 'text' && !k.value.trim()));
|
|
108
|
+
const first = kids[0];
|
|
109
|
+
if (!first || !isEl(first, 'p')) return null;
|
|
110
|
+
const lead = first.children?.[0];
|
|
111
|
+
const m = lead?.type === 'text' && lead.value.match(/^\s*\[!(NOTE|TIP|WARNING|STAT)\][ \t]*\r?\n?/i);
|
|
112
|
+
if (!m) return null;
|
|
113
|
+
const kind = m[1].toLowerCase();
|
|
114
|
+
const p = { ...first, children: [{ ...lead, value: lead.value.slice(m[0].length) }, ...first.children.slice(1)] };
|
|
115
|
+
const rest = kids.slice(1);
|
|
116
|
+
if (kind === 'stat') {
|
|
117
|
+
const text = p.children[0]?.type === 'text' ? p.children[0].value : '';
|
|
118
|
+
const nl = text.indexOf('\n');
|
|
119
|
+
const number = (nl === -1 ? text : text.slice(0, nl)).trim();
|
|
120
|
+
const after = nl === -1 ? [] : [{ type: 'text', value: text.slice(nl + 1) }, ...p.children.slice(1)];
|
|
121
|
+
const caption = [...(after.length && textOf({ children: after }).trim() ? [el('p', {}, after)] : []), ...rest];
|
|
122
|
+
walk({ children: caption });
|
|
123
|
+
return el('aside', { className: ['callout', 'callout-stat'] }, [el('p', { className: ['stat-number'] }, [{ type: 'text', value: number }]), el('div', { className: ['stat-caption'] }, caption)]);
|
|
124
|
+
}
|
|
125
|
+
const body = [...(textOf(p).trim() ? [p] : []), ...rest];
|
|
126
|
+
walk({ children: body });
|
|
127
|
+
return el('aside', { className: ['callout', `callout-${kind}`] }, [
|
|
128
|
+
el('p', { className: ['callout-title'] }, [icon(kind), el('span', {}, [{ type: 'text', value: LABELS[kind] }])]),
|
|
129
|
+
...body,
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
return (tree, file) => { if (/[\\/]content[\\/]blog[\\/]/.test(String(file?.path ?? ''))) walk(tree); };
|
|
133
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import ChevronDown from '@lucide/astro/icons/chevron-down';
|
|
3
3
|
import { render } from 'astro:content';
|
|
4
4
|
import blogImages from 'virtual:site-kit/blog-images';
|
|
5
|
+
import '../../styles/article.css';
|
|
5
6
|
import { Image, getImage } from 'astro:assets';
|
|
6
7
|
import { LICENCES } from '../../lib/blog-schema';
|
|
7
8
|
import Base from '@site/layouts/Base.astro';
|
|
@@ -66,6 +67,7 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
66
67
|
...imageObjects,
|
|
67
68
|
]}
|
|
68
69
|
>
|
|
70
|
+
<div class="read-progress" aria-hidden="true"><i></i></div>
|
|
69
71
|
<article class="post">
|
|
70
72
|
<header class="wrap head">
|
|
71
73
|
<nav class="crumbs" aria-label="Breadcrumb" data-enter>
|
|
@@ -79,6 +81,7 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
79
81
|
<time datetime={d.date.toISOString()}>{fmtDate(d.date)}</time>
|
|
80
82
|
{d.updated && d.updated.toISOString().slice(0, 10) > d.date.toISOString().slice(0, 10) && <> · Updated <time datetime={d.updated.toISOString()}>{fmtDate(d.updated)}</time></>}
|
|
81
83
|
<> · {minutes} min read</>
|
|
84
|
+
<button type="button" class="copy-link no-print" data-copy-link>Copy link</button>
|
|
82
85
|
{d.draft && <span class="draft"> · Draft, not published</span>}
|
|
83
86
|
</p>
|
|
84
87
|
{d.cover && (
|
|
@@ -101,12 +104,12 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
101
104
|
<ol>{toc.map((h) => <li><a href={`#${h.slug}`}>{h.text}</a></li>)}</ol>
|
|
102
105
|
</details>
|
|
103
106
|
)}
|
|
104
|
-
<div class="prose body" data-enter>
|
|
107
|
+
<div class="prose body article-body" data-enter>
|
|
105
108
|
<Content />
|
|
106
109
|
{(d.faq ?? []).length > 0 && (
|
|
107
110
|
<section class="post-faq" aria-labelledby="faq-h">
|
|
108
111
|
<h2 id="faq-h">Questions people ask</h2>
|
|
109
|
-
{(d.faq ?? []).map((f) =>
|
|
112
|
+
{(d.faq ?? []).map((f, i) => <details open={i === 0}><summary>{f.q}</summary><p>{f.a}</p></details>)}
|
|
110
113
|
</section>
|
|
111
114
|
)}
|
|
112
115
|
</div>
|
|
@@ -154,6 +157,38 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
154
157
|
</Base>
|
|
155
158
|
|
|
156
159
|
<script>
|
|
160
|
+
// A link icon beside each H2 copies that section's address.
|
|
161
|
+
document.querySelectorAll<HTMLElement>('.article-body h2[id]').forEach((h) => {
|
|
162
|
+
const a = document.createElement('a');
|
|
163
|
+
a.className = 'anchor';
|
|
164
|
+
a.href = `#${h.id}`;
|
|
165
|
+
a.textContent = '#';
|
|
166
|
+
a.setAttribute('aria-label', `Link to the section ${h.textContent}`);
|
|
167
|
+
a.addEventListener('click', () => { navigator.clipboard?.writeText(`${location.origin}${location.pathname}#${h.id}`).catch(() => {}); });
|
|
168
|
+
h.append(a);
|
|
169
|
+
});
|
|
170
|
+
// Copy the post's address; the button says so for a moment.
|
|
171
|
+
document.querySelector<HTMLButtonElement>('[data-copy-link]')?.addEventListener('click', (e) => {
|
|
172
|
+
const b = e.currentTarget as HTMLButtonElement;
|
|
173
|
+
navigator.clipboard?.writeText(location.href.split('#')[0]).then(() => {
|
|
174
|
+
b.textContent = 'Copied';
|
|
175
|
+
setTimeout(() => { b.textContent = 'Copy link'; }, 2000);
|
|
176
|
+
}).catch(() => {});
|
|
177
|
+
});
|
|
178
|
+
// Reading progress: how far down the article the page has scrolled.
|
|
179
|
+
const bar = document.querySelector<HTMLElement>('.read-progress i');
|
|
180
|
+
const article = document.querySelector<HTMLElement>('.article-body');
|
|
181
|
+
if (bar && article && !matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
182
|
+
let tick = 0;
|
|
183
|
+
const update = () => {
|
|
184
|
+
tick = 0;
|
|
185
|
+
const box = article.getBoundingClientRect();
|
|
186
|
+
const total = box.height - innerHeight * 0.5;
|
|
187
|
+
bar.style.setProperty('--p', String(Math.min(1, Math.max(0, (innerHeight * 0.25 - box.top) / total))));
|
|
188
|
+
};
|
|
189
|
+
addEventListener('scroll', () => { if (!tick) tick = requestAnimationFrame(update); }, { passive: true });
|
|
190
|
+
update();
|
|
191
|
+
}
|
|
157
192
|
// The side contents list marks the section being read.
|
|
158
193
|
const links = new Map([...document.querySelectorAll<HTMLAnchorElement>('[data-toc]')].map((a) => [a.dataset.toc!, a]));
|
|
159
194
|
if (links.size) {
|
|
@@ -201,36 +236,7 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
201
236
|
.takeaways h2 { margin: 0 0 var(--space-3); font-size: 1rem; line-height: 1.3; }
|
|
202
237
|
.takeaways ul { margin: 0; padding-left: 1.2em; display: grid; gap: var(--space-2); }
|
|
203
238
|
.takeaways li { font-size: 1.0625rem; line-height: 1.6; padding-left: 0.2em; }
|
|
204
|
-
.takeaways li::marker { color: var(--
|
|
205
|
-
|
|
206
|
-
/* Body text: serif, 18px, comfortable but not airy. */
|
|
207
|
-
.body { max-width: none; font-size: 1.0625rem; line-height: 1.7; }
|
|
208
|
-
.body :global(p), .body :global(ul), .body :global(ol) { margin: 0 0 1.1em; }
|
|
209
|
-
.body :global(li + li) { margin-top: 0.35em; }
|
|
210
|
-
.body :global(h2) { font-weight: 600; font-size: 1.5rem; line-height: 1.25; margin: 1.8em 0 0.6em; scroll-margin-top: 104px; }
|
|
211
|
-
.body :global(h3) { font-weight: 600; font-size: 1.1875rem; line-height: 1.3; margin: 1.5em 0 0.4em; scroll-margin-top: 104px; }
|
|
212
|
-
|
|
213
|
-
/* Tables: a bordered box that scrolls sideways, a header and first column that stay in view. */
|
|
214
|
-
.body :global(.table-scroll) { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--line); border-radius: var(--radius-panel); }
|
|
215
|
-
.body :global(table) { width: 100%; border-collapse: separate; border-spacing: 0; font-family: var(--font-sans); font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
|
|
216
|
-
.body :global(th), .body :global(td) { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
|
|
217
|
-
.body :global(th) { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--ink); font-weight: 600; }
|
|
218
|
-
.body :global(td) { background: var(--canvas); }
|
|
219
|
-
.body :global(tbody tr:nth-child(even) td) { background: color-mix(in srgb, var(--surface) 50%, var(--canvas)); }
|
|
220
|
-
.body :global(tbody tr:hover td) { background: var(--subtle); }
|
|
221
|
-
.body :global(tbody tr:last-child td) { border-bottom: 0; }
|
|
222
|
-
.body :global(th:first-child), .body :global(td:first-child) { position: sticky; left: 0; }
|
|
223
|
-
.body :global(th:first-child) { z-index: 2; }
|
|
224
|
-
.body :global(td:first-child) { font-weight: 500; }
|
|
225
|
-
.body :global(th.num), .body :global(td.num) { text-align: right; white-space: nowrap; }
|
|
226
|
-
.body :global(td a), .body :global(th a) { color: var(--link); }
|
|
227
|
-
@media (max-width: 599px) {
|
|
228
|
-
.body :global(table) { font-size: 14px; }
|
|
229
|
-
.body :global(th), .body :global(td) { padding: 8px 12px; }
|
|
230
|
-
}
|
|
231
|
-
.body :global(figure) { margin: 1.6em 0; }
|
|
232
|
-
.body :global(figure img), .body :global(img) { display: block; width: 100%; height: auto; margin: 0; border-radius: var(--radius-panel); background: var(--surface); }
|
|
233
|
-
.body :global(figcaption) { margin-top: var(--space-2); font-size: 14px; line-height: 1.45; color: var(--ink-muted); }
|
|
239
|
+
.takeaways li::marker { color: var(--mark); font-size: 1.1em; }
|
|
234
240
|
|
|
235
241
|
/* Contents on the right, sticky, current section in ink. */
|
|
236
242
|
.rail { position: relative; }
|
|
@@ -239,7 +245,7 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
239
245
|
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
|
|
240
246
|
.toc a { display: block; margin-left: -1px; padding: 7px 0 7px var(--space-4); border-left: 2px solid transparent; color: var(--ink-muted); font-size: 14px; line-height: 1.45; text-decoration: none; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
|
|
241
247
|
.toc a:hover { color: var(--ink); }
|
|
242
|
-
.toc a[aria-current] { color: var(--ink); font-weight: 500; border-left-color: var(--
|
|
248
|
+
.toc a[aria-current] { color: var(--ink); font-weight: 500; border-left-color: var(--mark); }
|
|
243
249
|
|
|
244
250
|
/* Tablet and phone: no rail; contents fold into a list under the takeaways. */
|
|
245
251
|
.toc-inline { display: none; margin: 0 0 var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-panel); }
|
|
@@ -276,10 +282,5 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
276
282
|
.post { padding-top: var(--space-4); }
|
|
277
283
|
.cover { margin: 0 calc(-1 * var(--gutter)) var(--space-6); }
|
|
278
284
|
.cover :global(img) { border-radius: 0; aspect-ratio: 3 / 2; }
|
|
279
|
-
.body { font-size: 1rem; line-height: 1.7; }
|
|
280
|
-
.body :global(h2) { font-size: 1.3125rem; }
|
|
281
|
-
.body :global(figure) { margin: 1.4em calc(-1 * var(--gutter)); }
|
|
282
|
-
.body :global(figure img) { border-radius: 0; }
|
|
283
|
-
.body :global(figcaption) { padding-inline: var(--gutter); }
|
|
284
285
|
}
|
|
285
286
|
</style>
|
|
@@ -101,11 +101,11 @@ const md = (x: string) => esc(x).replace(/\[([^\]]+)\]\((\/[^)\s]*)\)/g, (_, tex
|
|
|
101
101
|
.col { max-width: 720px; }
|
|
102
102
|
.back { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; color: var(--ink-muted); text-decoration: none; font-size: 16px; }
|
|
103
103
|
.back:hover { color: var(--ink); }
|
|
104
|
-
h1 { margin: var(--space-5) 0 var(--space-5); font-family:
|
|
104
|
+
h1 { margin: var(--space-5) 0 var(--space-5); font-family: var(--font-serif); font-weight: 600; font-size: clamp(2rem, 1.5rem + 2vw, 3rem); line-height: 1.12; }
|
|
105
105
|
/* The quotable one-line answer, set apart from the explanation. */
|
|
106
106
|
.def { margin: 0 0 var(--space-6); padding: var(--space-5) var(--space-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); font-size: 1.1875rem; line-height: 1.5; }
|
|
107
107
|
dfn { font-style: normal; font-weight: 600; }
|
|
108
|
-
.body { max-width: none; font-family:
|
|
108
|
+
.body { max-width: none; font-family: var(--font-serif); font-size: 1.125rem; line-height: 1.5; }
|
|
109
109
|
.body p { margin: 0 0 var(--space-4); }
|
|
110
110
|
.toc { margin: var(--space-6) 0; padding: var(--space-5) var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-panel); }
|
|
111
111
|
.toc ol { margin: var(--space-3) 0 0; padding-left: var(--space-5); font-size: 16px; line-height: 1.5; }
|
|
@@ -38,7 +38,7 @@ const terms = [...glossary].sort((a, b) => a.term.localeCompare(b.term));
|
|
|
38
38
|
display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr) auto; gap: var(--space-6); align-items: baseline;
|
|
39
39
|
padding: var(--space-5) 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none;
|
|
40
40
|
}
|
|
41
|
-
.name { font-family:
|
|
41
|
+
.name { font-family: var(--font-serif); font-size: 1.375rem; font-weight: 600; transition: color var(--fast) var(--ease); }
|
|
42
42
|
.full { display: block; font-family: var(--font-sans); font-size: 14px; font-weight: 400; color: var(--ink-muted); margin-top: 2px; }
|
|
43
43
|
.short { font-size: 16px; line-height: 1.5; color: var(--ink-muted); }
|
|
44
44
|
.terms :global(.go) { color: var(--ink-muted); transition: transform var(--fast) var(--ease), color var(--fast) var(--ease); }
|
|
@@ -15,7 +15,7 @@ const BANNED_COPY = [
|
|
|
15
15
|
[/social media chat|whatsapp|instagram|messenger|viber/i, 'social media chat is off the site'],
|
|
16
16
|
[/world[- ]class|supercharg|seamless|effortless|\bunlock\b|\belevate\b|cutting[- ]edge|revolutioni[sz]e|game[- ]chang/i, 'generic marketing claim'],
|
|
17
17
|
[/\bRs\.?\s?\d|NPR\s?\d|रु\s?\d/, 'price on the site'],
|
|
18
|
-
[/lorem ipsum
|
|
18
|
+
[/lorem ipsum|\bTODO\b|\bTBD\b/i, 'placeholder text'],
|
|
19
19
|
];
|
|
20
20
|
// Posts whose topic is the platforms themselves may name them.
|
|
21
21
|
const PLATFORM_NAMES_ALLOWED = new Set(config.check?.platformNamesAllowed ?? []);
|
|
@@ -28,6 +28,14 @@ const BANNED_CSS = [
|
|
|
28
28
|
[/text-transform\s*:\s*uppercase/, 'uppercase text'],
|
|
29
29
|
[/cubic-bezier\([^)]*-|cubic-bezier\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*1\.\d/, 'bounce easing'],
|
|
30
30
|
];
|
|
31
|
+
// Visible text with a space at every block and cell boundary, so "1 TB" in one
|
|
32
|
+
// table cell and "Days" in the next do not read as "TBDays".
|
|
33
|
+
const BLOCKS = new Set(['P', 'DIV', 'LI', 'UL', 'OL', 'TR', 'TD', 'TH', 'TABLE', 'THEAD', 'TBODY', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BR', 'SECTION', 'ARTICLE', 'ASIDE', 'HEADER', 'FOOTER', 'NAV', 'MAIN', 'FIGURE', 'FIGCAPTION', 'BLOCKQUOTE', 'DETAILS', 'SUMMARY', 'DT', 'DD', 'DL', 'PRE', 'LABEL', 'BUTTON']);
|
|
34
|
+
const spacedText = (node) => {
|
|
35
|
+
if (node.nodeType === 3) return node.rawText;
|
|
36
|
+
const inner = (node.childNodes ?? []).map(spacedText).join('');
|
|
37
|
+
return BLOCKS.has(node.rawTagName?.toUpperCase()) ? ` ${inner} ` : inner;
|
|
38
|
+
};
|
|
31
39
|
const SECRET = /sk_[A-Za-z0-9]{20,}|ELEVENLABS_API_KEY/;
|
|
32
40
|
|
|
33
41
|
export function canonicalFor(path) {
|
|
@@ -162,15 +170,15 @@ export function audit(dist, { designColours = DESIGN_COLOURS } = {}) {
|
|
|
162
170
|
// Copy checks run on visible text only.
|
|
163
171
|
for (const bad of root.querySelectorAll('script, style, noscript, template')) bad.remove();
|
|
164
172
|
const body = root.querySelector('body') ?? root;
|
|
165
|
-
const text = body.
|
|
173
|
+
const text = spacedText(body).replace(/\s+/g, ' ');
|
|
166
174
|
// Call transcripts quote callers' own words, including a shop's prices.
|
|
167
175
|
for (const t of body.querySelectorAll('[data-transcript]')) t.remove();
|
|
168
176
|
// Published prices live only inside [data-prices] (the pricing page).
|
|
169
177
|
for (const t of body.querySelectorAll('[data-prices]')) t.remove();
|
|
170
|
-
const ownText = body.
|
|
178
|
+
const ownText = spacedText(body).replace(/\s+/g, ' ');
|
|
171
179
|
// Legal pages describe the whole service, including app channels.
|
|
172
180
|
for (const t of body.querySelectorAll('[data-legal]')) t.remove();
|
|
173
|
-
const marketingText = body.
|
|
181
|
+
const marketingText = spacedText(body).replace(/\s+/g, ' ');
|
|
174
182
|
// Blog posts may quote sourced market prices (owner, 2026-10-19).
|
|
175
183
|
const isPost = /^blog\/[^/]+\.html$/.test(relative(dist, file)) && !/^blog\/(index|page|tag)/.test(relative(dist, file));
|
|
176
184
|
for (const [re, what] of BANNED_COPY) {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* Article body: the reading text of a blog post (and, later, a glossary term).
|
|
2
|
+
Flat: no shadows or gradients. Colours, fonts and radii come from the site's
|
|
3
|
+
tokens: --canvas --surface --subtle --line --ink --ink-muted --link
|
|
4
|
+
--mark (accent for markers and the progress bar) --warn-bg --warn-ink
|
|
5
|
+
--font-sans --font-display --font-mono --radius-panel. */
|
|
6
|
+
|
|
7
|
+
.prose.article-body { max-width: none; font-size: 1.0625rem; line-height: 1.7; }
|
|
8
|
+
.prose.article-body p, .prose.article-body ul, .prose.article-body ol { margin: 0 0 1.1em; }
|
|
9
|
+
.prose.article-body li + li { margin-top: 0.35em; }
|
|
10
|
+
.prose.article-body h2 { position: relative; font-weight: 600; font-size: 1.5rem; line-height: 1.25; margin: 1.8em 0 0.6em; scroll-margin-top: 104px; }
|
|
11
|
+
.prose.article-body h3 { font-weight: 600; font-size: 1.1875rem; line-height: 1.3; margin: 1.5em 0 0.4em; scroll-margin-top: 104px; }
|
|
12
|
+
|
|
13
|
+
/* A small "#" beside a heading that copies its link; shown on hover and focus. */
|
|
14
|
+
.prose.article-body .anchor { margin-left: 0.4em; color: var(--ink-muted); font-size: 0.8em; font-weight: 400; text-decoration: none; opacity: 0; transition: opacity var(--fast) var(--ease); }
|
|
15
|
+
.prose.article-body h2:hover .anchor, .prose.article-body .anchor:focus-visible { opacity: 1; }
|
|
16
|
+
.prose.article-body .anchor:hover { color: var(--link); }
|
|
17
|
+
@media (hover: none) { .prose.article-body .anchor { display: none; } }
|
|
18
|
+
|
|
19
|
+
/* Bullets take the accent; numbered lists become steps in circles. */
|
|
20
|
+
.prose.article-body ul > li::marker { color: var(--mark); }
|
|
21
|
+
.prose.article-body ol { list-style: none; padding-left: 0; counter-reset: step; }
|
|
22
|
+
.prose.article-body ol > li { position: relative; padding-left: 44px; min-height: 28px; counter-increment: step; }
|
|
23
|
+
.prose.article-body ol > li + li { margin-top: 0.6em; }
|
|
24
|
+
.prose.article-body ol > li::before { content: counter(step); position: absolute; left: 0; top: 0.1em; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--subtle); color: var(--link); font-family: var(--font-display); font-size: 0.875rem; font-weight: 600; line-height: 1; }
|
|
25
|
+
|
|
26
|
+
/* Quotes: larger text and a quote mark, no stripe. */
|
|
27
|
+
.prose.article-body blockquote { position: relative; margin: 1.6em 0; padding: 1.4em 0 0; border: 0; color: var(--ink); font-size: 1.25rem; line-height: 1.5; }
|
|
28
|
+
.prose.article-body blockquote::before { content: '\201C'; position: absolute; top: -0.15em; left: 0; color: var(--ink-muted); font-family: var(--font-display); font-size: 3rem; line-height: 1; }
|
|
29
|
+
.prose.article-body blockquote p { margin: 0 0 0.6em; }
|
|
30
|
+
|
|
31
|
+
/* Callouts from > [!NOTE], [!TIP], [!WARNING] and [!STAT]. */
|
|
32
|
+
.prose.article-body .callout { margin: 1.6em 0; padding: 18px 20px; border-radius: var(--radius-panel); background: var(--surface); color: var(--ink); }
|
|
33
|
+
.prose.article-body .callout > :last-child { margin-bottom: 0; }
|
|
34
|
+
.prose.article-body .callout-title { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-2); font-family: var(--font-display); font-weight: 600; }
|
|
35
|
+
.prose.article-body .callout-title svg { flex: none; }
|
|
36
|
+
.prose.article-body .callout-warning { background: var(--warn-bg); color: var(--warn-ink); }
|
|
37
|
+
.prose.article-body .callout-warning .callout-title, .prose.article-body .callout-warning a { color: var(--warn-ink); }
|
|
38
|
+
.prose.article-body .callout-stat .stat-number { margin: 0; font-family: var(--font-display); font-size: 2rem; font-weight: 600; line-height: 1.15; }
|
|
39
|
+
.prose.article-body .callout-stat .stat-caption { margin-top: var(--space-1); font-size: 15px; line-height: 1.5; color: var(--ink-muted); }
|
|
40
|
+
.prose.article-body .callout-stat .stat-caption p { margin: 0; }
|
|
41
|
+
|
|
42
|
+
/* Tables: a bordered box that scrolls sideways, a header and first column that stay in view. */
|
|
43
|
+
.prose.article-body .table-scroll { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--line); border-radius: var(--radius-panel); }
|
|
44
|
+
.prose.article-body table { width: 100%; border-collapse: separate; border-spacing: 0; font-family: var(--font-sans); font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
|
|
45
|
+
.prose.article-body th, .prose.article-body td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
|
|
46
|
+
.prose.article-body th { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--ink); font-weight: 600; }
|
|
47
|
+
.prose.article-body td { background: var(--canvas); }
|
|
48
|
+
.prose.article-body tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface) 50%, var(--canvas)); }
|
|
49
|
+
.prose.article-body tbody tr:hover td { background: var(--subtle); }
|
|
50
|
+
.prose.article-body tbody tr:last-child td { border-bottom: 0; }
|
|
51
|
+
.prose.article-body th:first-child, .prose.article-body td:first-child { position: sticky; left: 0; }
|
|
52
|
+
.prose.article-body th:first-child { z-index: 2; }
|
|
53
|
+
.prose.article-body td:first-child { font-weight: 500; }
|
|
54
|
+
.prose.article-body th.num, .prose.article-body td.num { text-align: right; white-space: nowrap; }
|
|
55
|
+
.prose.article-body td a, .prose.article-body th a { color: var(--link); }
|
|
56
|
+
|
|
57
|
+
/* Figures: on wide screens they reach into the contents rail's space. */
|
|
58
|
+
.prose.article-body figure { margin: 1.6em 0; }
|
|
59
|
+
.prose.article-body figure img, .prose.article-body img { display: block; width: 100%; height: auto; margin: 0; border-radius: var(--radius-panel); background: var(--surface); }
|
|
60
|
+
.prose.article-body figcaption { margin-top: var(--space-2); font-size: 14px; line-height: 1.45; color: var(--ink-muted); }
|
|
61
|
+
@media (min-width: 1100px) {
|
|
62
|
+
.prose.article-body figure { width: min(900px, calc(100% + 220px)); max-width: none; }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Questions people ask: an accordion, first answer open. */
|
|
66
|
+
.post-faq { margin-top: var(--space-7); }
|
|
67
|
+
.post-faq > h2 { margin-bottom: var(--space-3); }
|
|
68
|
+
.post-faq details { border-bottom: 1px solid var(--line); }
|
|
69
|
+
.post-faq details:first-of-type { border-top: 1px solid var(--line); }
|
|
70
|
+
.post-faq summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 48px; padding: var(--space-3) 0; cursor: pointer; list-style: none; font-family: var(--font-display); font-size: 1.0625rem; font-weight: 600; line-height: 1.35; }
|
|
71
|
+
.post-faq summary::-webkit-details-marker { display: none; }
|
|
72
|
+
.post-faq summary::after { content: '+'; flex: none; color: var(--link); font-size: 1.5rem; font-weight: 400; line-height: 1; transition: transform var(--fast) var(--ease); }
|
|
73
|
+
.post-faq details[open] summary::after { transform: rotate(45deg); }
|
|
74
|
+
.post-faq summary:hover { color: var(--link); }
|
|
75
|
+
.post-faq details p { margin: 0 0 var(--space-4); max-width: 62ch; }
|
|
76
|
+
|
|
77
|
+
/* Reading progress: a thin bar at the top of the page, moved with a transform. */
|
|
78
|
+
.read-progress { position: fixed; inset: 0 0 auto 0; z-index: 60; height: 3px; pointer-events: none; }
|
|
79
|
+
.read-progress i { display: block; height: 100%; background: var(--mark); transform: scaleX(var(--p, 0)); transform-origin: left; }
|
|
80
|
+
@media (prefers-reduced-motion: reduce) { .read-progress { display: none; } }
|
|
81
|
+
@media print { .read-progress, .copy-link { display: none; } }
|
|
82
|
+
|
|
83
|
+
/* "Copy link" beside the date line. */
|
|
84
|
+
.copy-link { margin-left: var(--space-2); padding: 2px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); background: transparent; color: var(--ink-muted); font: inherit; font-size: 14px; cursor: pointer; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
|
|
85
|
+
.copy-link:hover { color: var(--link); border-color: var(--link); }
|
|
86
|
+
|
|
87
|
+
@media (max-width: 599px) {
|
|
88
|
+
.prose.article-body { font-size: 1rem; line-height: 1.7; }
|
|
89
|
+
.prose.article-body h2 { font-size: 1.3125rem; }
|
|
90
|
+
.prose.article-body table { font-size: 14px; }
|
|
91
|
+
.prose.article-body th, .prose.article-body td { padding: 8px 12px; }
|
|
92
|
+
.prose.article-body figure { margin: 1.4em calc(-1 * var(--gutter)); }
|
|
93
|
+
.prose.article-body figure img { border-radius: 0; }
|
|
94
|
+
.prose.article-body figcaption { padding-inline: var(--gutter); }
|
|
95
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* Blog: headings and post titles in the reading serif. */
|
|
2
|
-
.blog-serif h1, .blog-serif h2, .blog-serif h3 { font-family:
|
|
2
|
+
.blog-serif h1, .blog-serif h2, .blog-serif h3 { font-family: var(--font-serif); font-weight: 600; }
|